package mycine.model.beans;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;

/**
 *
 * @author Vincent
 */
@Entity
@Table(name = "film")
@NamedQueries({
	@NamedQuery(name = "Film.findAll", query = "SELECT f FROM Film f"),
	@NamedQuery(name = "Film.findById", query = "SELECT f FROM Film f WHERE f.id = :id"),
	@NamedQuery(name = "Film.findByTitle", query = "SELECT f FROM Film f WHERE f.title = :title"),
	@NamedQuery(name = "Film.findByYearProduct", query = "SELECT f FROM Film f WHERE f.yearProduct = :yearProduct"),
	@NamedQuery(name = "Film.findByDirector", query = "SELECT f FROM Film f WHERE f.director = :director")})
public class Film implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
	private Integer id;
	@Basic(optional = false)
    @Column(name = "title")
	private String title;
	@Column(name = "yearProduct")
	private Integer yearProduct;
	@Lob
    @Column(name = "description")
	private String description;
	@Basic(optional = false)
    @Column(name = "director")
	private int director;
	@ManyToMany(mappedBy = "filmList")
	private List<Usermc> usermcList;
	@JoinTable(name = "actor", joinColumns = {
    	@JoinColumn(name = "film", referencedColumnName = "id")}, inverseJoinColumns = {
    	@JoinColumn(name = "person", referencedColumnName = "id")})
    @ManyToMany
	private List<Person> personList;
	@JoinColumn(name = "genre", referencedColumnName = "id")
    @ManyToOne
	private Genre genre;

	public Film() {
	}

	public Film(Integer id) {
		this.id = id;
	}

	public Film(Integer id, String title, int director) {
		this.id = id;
		this.title = title;
		this.director = director;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Integer getYearProduct() {
		return yearProduct;
	}

	public void setYearProduct(Integer yearProduct) {
		this.yearProduct = yearProduct;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getDirector() {
		return director;
	}

	public void setDirector(int director) {
		this.director = director;
	}

	public List<Usermc> getUsermcList() {
		return usermcList;
	}

	public void setUsermcList(List<Usermc> usermcList) {
		this.usermcList = usermcList;
	}

	public List<Person> getPersonList() {
		return personList;
	}

	public void setPersonList(List<Person> personList) {
		this.personList = personList;
	}

	public Genre getGenre() {
		return genre;
	}

	public void setGenre(Genre genre) {
		this.genre = genre;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Film)) {
			return false;
		}
		Film other = (Film) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "mycine.model.beans.Film[ id=" + id + " ]";
	}
	
}
